package com.haixiaoke.saas.order.service.impl;

import java.time.LocalDate;
import java.util.Date;
import java.util.List;

import com.haixiaoke.saas.common.utils.DateUtils;
import com.haixiaoke.saas.order.domain.OrderHousingExpenses;
import com.haixiaoke.saas.order.mapper.OrderHousingExpensesMapper;
import com.haixiaoke.saas.order.service.IOrderHousingExpensesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 订单每日房费详情Service业务层处理
 * 
 * @author panda
 * @date 2024-04-03
 */
@Service
public class OrderHousingExpensesServiceImpl implements IOrderHousingExpensesService {
    @Autowired
    private OrderHousingExpensesMapper orderHousingExpensesMapper;

    /**
     * 查询订单每日房费详情
     * 
     * @param id 订单每日房费详情主键
     * @return 订单每日房费详情
     */
    @Override
    public OrderHousingExpenses selectOrderHousingExpensesById(Long id) {
        return orderHousingExpensesMapper.selectOrderHousingExpensesById(id);
    }

    /**
     * 查询订单每日房费详情列表
     * 
     * @param orderHousingExpenses 订单每日房费详情
     * @return 订单每日房费详情
     */
    @Override
    public List<OrderHousingExpenses> selectOrderHousingExpensesList(OrderHousingExpenses orderHousingExpenses) {
        return orderHousingExpensesMapper.selectOrderHousingExpensesList(orderHousingExpenses);
    }

    /**
     * 新增订单每日房费详情
     * 
     * @param orderHousingExpenses 订单每日房费详情
     * @return 结果
     */
    @Override
    public int insertOrderHousingExpenses(OrderHousingExpenses orderHousingExpenses) {
        orderHousingExpenses.setCreateTime(DateUtils.getNowDate());
        return orderHousingExpensesMapper.insertOrderHousingExpenses(orderHousingExpenses);
    }

    /**
     * 修改订单每日房费详情
     * 
     * @param orderHousingExpenses 订单每日房费详情
     * @return 结果
     */
    @Override
    public int updateOrderHousingExpenses(OrderHousingExpenses orderHousingExpenses) {
        orderHousingExpenses.setUpdateTime(DateUtils.getNowDate());
        return orderHousingExpensesMapper.updateOrderHousingExpenses(orderHousingExpenses);
    }

    /**
     * 批量删除订单每日房费详情
     * 
     * @param ids 需要删除的订单每日房费详情主键
     * @return 结果
     */
    @Override
    public int deleteOrderHousingExpensesByIds(Long[] ids) {
        return orderHousingExpensesMapper.deleteOrderHousingExpensesByIds(ids);
    }

    /**
     * 删除订单每日房费详情信息
     * 
     * @param id 订单每日房费详情主键
     * @return 结果
     */
    @Override
    public int deleteOrderHousingExpensesById(Long id) {
        return orderHousingExpensesMapper.deleteOrderHousingExpensesById(id);
    }

    @Override
    public List<LocalDate> selectRentingTimeByHouseIdAndTime(String houseId, Date startTime, Date endTime) {
        return orderHousingExpensesMapper.selectRentingTimeByHouseIdAndTime(houseId,startTime,endTime);
    }

    @Override
    public int insertBatchOrderHousingExpenses(List<OrderHousingExpenses> orderHousingExpensesList) {
        return orderHousingExpensesMapper.insertBatchOrderHousingExpenses(orderHousingExpensesList);
    }

    /**
     * 查询这个订单下的房费收费详情
     * @param orderId
     * @return
     */
    @Override
    public List<OrderHousingExpenses> selectHousingExpensesByOrderId(String orderId,boolean afterFlag) {
        return orderHousingExpensesMapper.selectHousingExpensesByOrderId(orderId,afterFlag);
    }

    @Override
    public OrderHousingExpenses selectOrderHousingExpensesByDate(String orderId, LocalDate nowDate) {
        return orderHousingExpensesMapper.selectOrderHousingExpensesByDate(orderId,nowDate);
    }

    @Override
    public List<OrderHousingExpenses> selectHousingExpensesByOrderIdOrLinkedOrderId(String orderId, boolean afterFlag) {
        return orderHousingExpensesMapper.selectHousingExpensesByOrderIdOrLinkedOrderId(orderId,afterFlag);
    }

    @Override
    public int updateExpensesByOrderIdAndLinkedOrderId(String orderId, String houseId) {
        return orderHousingExpensesMapper.updateExpensesByOrderIdAndLinkedOrderId(orderId,houseId);
    }
}
